package as2.model;

import org.hibernate.Session;

public class DataService {
	protected static Session getSession() {
		return HibernateUtil.getSession();
	}

	/**
	 * Update the modified object into db
	 * 
	 * @param data
	 */
	public static void update(Object data) {
		Session session = getSession();
		session.beginTransaction();
		getSession().update(data);
		session.getTransaction().commit();
	}

	/**
	 * Save a new object into db
	 * 
	 * @param data
	 */
	public static void save(Object data) {
		Session session = getSession();
		session.beginTransaction();
		session.save(data);
		session.getTransaction().commit();
	}

	public static void refresh(Object data) {
		Session session = getSession();
		session.beginTransaction();
		session.refresh(data);
		session.getTransaction().commit();
	}
}
